package com.galen.manual.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.galen.manual.entity.Settlement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface SettlementMapper extends BaseMapper<Settlement> {

    /**
     * 根据用户ID查询结算单列表
     */
    List<Settlement> selectByUserId(@Param("userId") Long userId);

    /**
     * 根据用户ID和时间范围查询结算单
     */
    Settlement selectByUserIdAndPeriod(@Param("userId") Long userId,
                                      @Param("startTime") LocalDateTime startTime,
                                      @Param("endTime") LocalDateTime endTime);

    /**
     * 统计用户结算总金额
     */
    BigDecimal sumFinalAmountByUserId(@Param("userId") Long userId);

    /**
     * 批量更新结算状态
     */
    int updateStatusBatch(@Param("settlementIds") List<Long> settlementIds, @Param("status") Integer status);
}